package cc.magicjson.mall.order.domain.model;



import cc.magicjson.mall.common.domain.ValueObject;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.Currency;

/**
 * Money 值对象
 */
@Getter
public class Money implements ValueObject {
    public static final Money ZERO = new Money(BigDecimal.ZERO, Currency.getInstance("USD"));

    private final BigDecimal amount;
    private final Currency currency;

    public Money(BigDecimal amount, Currency currency) {
        this.amount = amount;
        this.currency = currency;
    }

    public Money add(Money other) {
        if (!this.currency.equals(other.currency)) {
            throw new IllegalArgumentException("Cannot add money with different currencies");
        }
        return new Money(this.amount.add(other.amount), this.currency);
    }

    public Money multiply(int multiplier) {
        return new Money(this.amount.multiply(BigDecimal.valueOf(multiplier)), this.currency);
    }

    // Getters
}